<?php
/**
 * Helper class for Hello World! module
 * 
 * @package    Joomla.Tutorials
 * @subpackage Modules
 * @link http://dev.joomla.org/component/option,com_jd-wiki/Itemid,31/id,tutorials:modules/
 * @license        GNU/GPL, see LICENSE.php
 * mod_helloworld is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 */
class modSstable1Helper
{
    /**
     * Retrieves the hello message
     *
     * @param array $params An object containing the module parameters
     * @access public
     */    
    function getHello( $params )
    {
        return 'Hello, World!('.$params.')';
    }
	private function read_all_files($root = '.') {
		$files = array (
				'files' => array (),
				'dirs' => array () 
		);
		$directories = array ();
		$last_letter = $root [strlen ( $root ) - 1];
		$root = ($last_letter == '\\' || $last_letter == '/') ? $root : $root . DIRECTORY_SEPARATOR;
		
		$directories [] = $root;
		
		while ( sizeof ( $directories ) ) {
			$dir = array_pop ( $directories );
			if ($handle = opendir ( $dir )) {
				while ( false !== ($file = readdir ( $handle )) ) {
					if ($file == '.' || $file == '..' || $file == '.DS_Store') {
						continue;
					}
					$file = $dir . $file;
					if (is_dir ( $file )) {
						$directory_path = $file . DIRECTORY_SEPARATOR;
						array_push ( $directories, $directory_path );
						$files ['dirs'] [] = $directory_path;
					} elseif (is_file ( $file )) {
						$files ['files'] [] = $file;
					}
				}
				closedir ( $handle );
			}
		}
		
		return $files;
	}
    function getImgRandom(){
    	$result = self::read_all_files('images/thumbnail/100/Gallery');
    	shuffle($result['files']);
    	return array_slice($result['files'], 0, 50);
    }
    
    function getImg205Random(){
    	$result = self::read_all_files('images/thumbnail/205/Gallery');
    	shuffle($result['files']);
    	return array_slice($result['files'], 0, 20);
    }
}
?>